const Boke = require("../models/bokecontent")

exports.getboke=async function (){
    const result=await Boke.findAll()
    return result;
}
exports.addBoke = async function (obj) {
    const ins = await Boke.create(obj)
    return ins.toJSON()
}

exports.deleteBoke = async function (id) {
    return await Boke.destroy({
        where: {
            id
        }
    });
}

exports.getBokeById = async function (id) {
    const result = await Boke.findByPk(id);
    if (result) {
        return result.toJSON()
    }
    return null
}

exports.updateBoke = async function (id, obj) {
    return await Boke.update(obj, {
        where: {
            id
        }
    });
}

// 分页查询
const {
    Op, where
} = require("sequelize")
exports.getfindall= async function (page = 1, limit = 5) {

    const result = await Txt.findAndCountAll({
        offset: (page - 1) * limit,
        limit: +limit,
    
    })
    return JSON.parse(JSON.stringify(result))
}

exports.getIdfind = async function (id) {
    const result = await Boke.findOne({
        where:{
            id
        }
    });
    return result.toJSON()
}